<template>
  <div>
    <el-container class="home-container">
      <el-header class="home-header">
        <span class="home_title">快速开发平台</span>
        <el-dropdown @command="handleCommand"> 
          <span>{{this.$store.state.user.username}}</span>
          <i class="el-icon-setting" style="margin-right: 15px"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click="logout()">退出登录</el-dropdown-item>
         
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>

      <el-container>
        <el-aside width="200px" class="home-aside">
          <el-menu router :unique-opened="true"	>
            <el-submenu :index="index+''"  v-for="(item,index) in this.$router.options.routes[1].children">
              <template slot="title">
                <i class="el-icon-message"></i>{{item.name}}
              </template>
              <el-menu-item-group>
                <el-menu-item :index="sub.path"  v-for="sub in item.children">{{sub.name}}</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {};
  },
  mounted() {
    console.log("111111111111111111111111111111111111111{}",this.$router.options.routes[1].children);
  },methods:{
      handleCommand(){
       
          var $this = this;
          this.$ajax({
              method:'get',
              url: 'http://localhost:8081/my/logout'
          }).then(function(res){
              console.log(res);
             $this.$message(res.data.msg);
              if(res.data.code==200){
                   localStorage.removeItem('user');
                    $this.$store.state.rs=[];
                    $this.$store.state.user='';
                    $this.$router.replace({path:"/"});
                    return;
              }
          })
      }
  }
};
</script>
<style>
.home-container {
  height: 100%;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
}
.home-header {
  background-color: #20a0ff;
  color: #333;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: content-box;
  padding: 15px;
}
.home_title {
  color: #fff;
  font-size: 22px;
  display: inline;
  margin-left: 8px;
}
.home-aside {
  background-color: #ececec;
}
</style>